package main

import (
	"fmt"
	"net/http"

	"github.com/hu17889/go_spider/core/common/request"
	"github.com/hu17889/go_spider/core/spider"
)

func assertErr(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	const url string = "https://www1.ludashi.com/web/getRankingList"

	var reqs []*request.Request
	for _, platform := range []string{"desktop", "notebook", "server"} {
		for _, cores := range []string{"", "single", "multi"} {
			reqs = append(reqs, request.NewRequest(url, "json",
				fmt.Sprintf("%s|%s", platform, cores), "POST",
				fmt.Sprintf("which=web_cpu&platformType=%s&whichList=%s", platform, cores),
				http.Header{
					"Content-Type": []string{"application/x-www-form-urlencoded"},
				}, nil, nil, nil))
		}
	}
	spider.NewSpider(NewLuDaShiProcessor(), "LuDashi").
		SetSleepTime("rand", 1000, 2000).SetThreadnum(1).GetAllByRequest(reqs)
}
